﻿@model NB.MGJ.Model.LogOnModel
@{
    Layout = "~/Views/Shared/_Layout_Home.cshtml";
}
<style type="text/css">
    .validation-summary-errors ul li {
        height: 40px;
        line-height: 40px;
        margin: 0;
    }

    .validation-summary-errors {
        width: 90%;
    }

        .validation-summary-errors li {
            font-size: 11px;
            text-align: center;
            padding: 0;
            border: 0;
            border-color: #e18d9a;
            color: #f0f0f0;
            background: rgb(246,116,116);
        }

    .glyphicon {
        top: 0;
    }
</style>
<div style="height: 100%;">
    <div class="window-back">
        <div id="body_div">
           @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @id = "logon_form", @class = "login_form" }))
           {
                <p style="margin: 50px 0 0 50px">账号登录</p>
                <div class="error_msg">
                      @Html.ValidationSummary(true)
                      @Html.Hidden("returnUrl", Request["returnUrl"])
                 </div>
                <div class="login_div">
                    <label for="yonghu" class="glyphicon glyphicon-user"></label>
                    @Html.TextBoxFor(p => p.UserName, new { @autofocus = "autofocus", @placeholder = "输入用户名", @class = "form-control", @id = "yonghu" })
                </div>
                <div class="login_div">
                    <label for="mima" class="glyphicon glyphicon-lock"></label>
                    @Html.PasswordFor(p => p.Password, new { @autofocus = "autofocus", @placeholder = "输入密码", @class = "form-control", @id = "mima" })
                </div>
                <div id="checkbox_div">
                    <input type="checkbox" id="isRemember" />
                    <label for="isRemember">是否记住密码</label>
                </div>
                <input id="_submint" type="submit" value="登录" onclick="check()"/>
            }
        </div>
    </div>
    <div class="swiper-container banner-pager" id="swiper-top">
        <div class="swiper-wrapper">
            @*<div class="swiper-slide">
                <div class="swiper-zoom-container swiper-top-1">
                    <div class="banner-absolute">
                        <div class="border-layer">
                            <ol class="list-paddingleft-2">
                                <li>
                                    <p><br></p>
                                </li>
                                <li>
                                    <p>
                                    <br></p>
                                </li>
                                <li>
                                    <p><br></p>
                                </li>
                                <li>
                                    <p><br></p>
                                </li>
                            </ol>
                            <ul class="list-paddingleft-2">
                                <li>
                                    <p><br></p>
                                </li>
                                <li>
                                    <p><br></p>
                                </li>
                                <li>
                                    <p><br></p>
                                </li>
                                <li>
                                    <p><br></p>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>*@
            <div class="swiper-slide">
                <div class="swiper-zoom-container  swiper-top-2"></div>
            </div>
            <div class="swiper-slide">
                <div class="swiper-zoom-container  swiper-top-3"></div>
            </div>
            <div class="swiper-slide">
                <div class="swiper-zoom-container  swiper-top-4"></div>
            </div>
        </div>
        <div class="swiper-pagination swiper-pagination-white"></div>
    </div>
</div>
<script>
    function setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
        var expires = "expires=" + d.toGMTString();
        document.cookie = cname + "=" + cvalue + "; " + expires;
    }
    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i].trim();
            if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
        }
        return "";
    }
    function delCookie() {
        document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
    function check() {
        //获取表单输入:用户名,密码,是否保存密码
        var username = document.getElementById("yonghu").value.trim();
        var password = document.getElementById("mima").value.trim();
        var isRmbPwd = document.getElementById("isRemember").checked;

        //判断用户名,密码是否为空(全空格也算空)
        if (username.length != 0 && password.length != 0) {
            //若复选框勾选,则添加Cookie,记录密码
            if (isRmbPwd == true) {
                setCookie("username", username, 7);
                setCookie(username, password, 7);
            }
                //否则清除Cookie
            else {
                delCookie();
            }
        }
            //非法输入提示
        else {
            return;
        }
    }

    //将function函数赋值给onload对象
    window.onload = function () {
   
        //从Cookie获取到用户名
        var username = getCookie("username");
        //如果用户名为空,则给表单元素赋空值
        if (username == "") {
            document.getElementById("yonghu").value = "";
            document.getElementById("mima").value = "";
            document.getElementById("isRemember").checked = false;
        }
            //获取对应的密码,并把用户名,密码赋值给表单
        else {
            var password = getCookie(username);
            document.getElementById("yonghu").value = username;
            document.getElementById("mima").value = password;
            document.getElementById("isRemember").checked = true;
        }
    }
</script>



